package com.mazaiting.ftp.domain.entity;

import java.util.Objects;

/**
 * FTP用户配置信息
 *
 * @title: FtpEntyit
 * @Author danghailiang
 * @Date: 2022/4/18 15:52
 * @Version 1.0
 */
public class FtpConfig {

    /**
     * ftp 地址
     */
    private String host;
    /**
     * 端口号
     */
    private int port;
    /**
     * 用户名
     */
    private String username;
    /**
     * 密码
     */
    private String password;

    /**
     * 服务器根路径
     */
    private String rootPath = "/";

    public FtpConfig(String host, int port, String username, String password) {
        this(host, port, username, password, null);
    }

    public FtpConfig(String host, int port, String username, String password, String rootPath) {
        this.host = host;
        this.port = port;
        this.username = username;
        this.password = password;
        // 判断是否传入新的路径名，没有则 默认用户名
        if (Objects.isNull(rootPath) || rootPath.isEmpty()) {
            this.rootPath += username;
        } else {
            this.rootPath = rootPath;
        }

    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public String getRootPath() {
        return rootPath;
    }

    public void setRootPath(String rootPath) {
        this.rootPath = rootPath;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
}
